Patch "1a" from #136185, by Morten Welinder.
authorFederico Mena Quintero <federico@ximian.com>
Mon, 8 Mar 2004 22:53:35 +0000 (22:53 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Mon, 8 Mar 2004 22:53:35 +0000 (22:53 +0000)
2004-03-08  Federico Mena Quintero  <federico@ximian.com>

Patch "1a" from #136185, by Morten Welinder.

* gtk/gtkfilechooserdefault.c (get_file_info): Take in an argument
that says whether the caller just wants the display name.
(shortcuts_insert_path): We only want the name in the call to
get_file_info().

* gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't request more
info than needed from the file_folder.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c
gtk/gtkpathbar.c

index 0dba3d3259d0c14ed79017bdb87db35342539dc2..24ee7fa95959d7444e724e15be88fbc5e023f5f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-03-08  Federico Mena Quintero  <federico@ximian.com>
+
+       Patch "1a" from #136185, by Morten Welinder.
+
+       * gtk/gtkfilechooserdefault.c (get_file_info): Take in an argument
+       that says whether the caller just wants the display name.
+       (shortcuts_insert_path): We only want the name in the call to
+       get_file_info().
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't request more
+       info than needed from the file_folder.
+
 2004-03-08  Federico Mena Quintero  <federico@ximian.com>
 
        Fixes #136105.
index 0dba3d3259d0c14ed79017bdb87db35342539dc2..24ee7fa95959d7444e724e15be88fbc5e023f5f3 100644 (file)
@@ -1,3 +1,15 @@
+2004-03-08  Federico Mena Quintero  <federico@ximian.com>
+
+       Patch "1a" from #136185, by Morten Welinder.
+
+       * gtk/gtkfilechooserdefault.c (get_file_info): Take in an argument
+       that says whether the caller just wants the display name.
+       (shortcuts_insert_path): We only want the name in the call to
+       get_file_info().
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't request more
+       info than needed from the file_folder.
+
 2004-03-08  Federico Mena Quintero  <federico@ximian.com>
 
        Fixes #136105.
index 0dba3d3259d0c14ed79017bdb87db35342539dc2..24ee7fa95959d7444e724e15be88fbc5e023f5f3 100644 (file)
@@ -1,3 +1,15 @@
+2004-03-08  Federico Mena Quintero  <federico@ximian.com>
+
+       Patch "1a" from #136185, by Morten Welinder.
+
+       * gtk/gtkfilechooserdefault.c (get_file_info): Take in an argument
+       that says whether the caller just wants the display name.
+       (shortcuts_insert_path): We only want the name in the call to
+       get_file_info().
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't request more
+       info than needed from the file_folder.
+
 2004-03-08  Federico Mena Quintero  <federico@ximian.com>
 
        Fixes #136105.
index 0dba3d3259d0c14ed79017bdb87db35342539dc2..24ee7fa95959d7444e724e15be88fbc5e023f5f3 100644 (file)
@@ -1,3 +1,15 @@
+2004-03-08  Federico Mena Quintero  <federico@ximian.com>
+
+       Patch "1a" from #136185, by Morten Welinder.
+
+       * gtk/gtkfilechooserdefault.c (get_file_info): Take in an argument
+       that says whether the caller just wants the display name.
+       (shortcuts_insert_path): We only want the name in the call to
+       get_file_info().
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't request more
+       info than needed from the file_folder.
+
 2004-03-08  Federico Mena Quintero  <federico@ximian.com>
 
        Fixes #136105.
index 0dba3d3259d0c14ed79017bdb87db35342539dc2..24ee7fa95959d7444e724e15be88fbc5e023f5f3 100644 (file)
@@ -1,3 +1,15 @@
+2004-03-08  Federico Mena Quintero  <federico@ximian.com>
+
+       Patch "1a" from #136185, by Morten Welinder.
+
+       * gtk/gtkfilechooserdefault.c (get_file_info): Take in an argument
+       that says whether the caller just wants the display name.
+       (shortcuts_insert_path): We only want the name in the call to
+       get_file_info().
+
+       * gtk/gtkpathbar.c (_gtk_path_bar_set_path): Don't request more
+       info than needed from the file_folder.
+
 2004-03-08  Federico Mena Quintero  <federico@ximian.com>
 
        Fixes #136105.
index e24d3edd8a62194e782b90e0b0496ee7f6011883..7ff108d346119c3716eb86028c01ed3f1c066c7e 100644 (file)
@@ -751,7 +751,7 @@ shortcuts_unselect_all (GtkFileChooserDefault *impl)
 
 /* Convenience function to get the display name and icon info for a path */
 static GtkFileInfo *
-get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, GError **error)
+get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean name_only, GError **error)
 {
   GtkFilePath *parent_path;
   GtkFileFolder *parent_folder;
@@ -765,7 +765,7 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, GError **err
 #if 0
                                              | GTK_FILE_INFO_ICON
 #endif
-                                             | GTK_FILE_INFO_IS_FOLDER,
+                                             | (name_only ? 0 : GTK_FILE_INFO_IS_FOLDER),
                                              error);
   gtk_file_path_free (parent_path);
 
@@ -808,22 +808,19 @@ shortcuts_insert_path (GtkFileChooserDefault *impl,
     }
   else
     {
-      GtkFileInfo *info;
-
-      info = get_file_info (impl->file_system, path, error);
-      if (!info)
-       return FALSE;
-
-      data = gtk_file_path_copy (path);
-
       if (label)
        label_copy = g_strdup (label);
       else
-       label_copy = g_strdup (gtk_file_info_get_display_name (info));
+       {
+         GtkFileInfo *info = get_file_info (impl->file_system, path, TRUE, error);
+         if (!info)
+           return FALSE;
+         label_copy = g_strdup (gtk_file_info_get_display_name (info));
+         gtk_file_info_free (info);
+       }
 
+      data = gtk_file_path_copy (path);
       pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl), ICON_SIZE, NULL);
-
-      gtk_file_info_free (info);
     }
 
   if (pos == -1)
@@ -1426,7 +1423,7 @@ shortcuts_add_bookmark_from_path (GtkFileChooserDefault *impl,
     return;
 
   error = NULL;
-  info = get_file_info (impl->file_system, path, &error);
+  info = get_file_info (impl->file_system, path, FALSE, &error);
 
   if (!info)
     error_getting_info_dialog (impl, path, error);
@@ -2879,14 +2876,16 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser    *chooser,
                                             GError           **error)
 {
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
-  GError *err;
+  GtkFileInfo *info;
 
-  err = NULL;
-  if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, &err))
-    {
-      g_propagate_error (error, err);
-      return FALSE;
-    }
+  /* Test validity of path here.  */
+  info = get_file_info (impl->file_system, path, FALSE, error);
+  if (!info)
+    return FALSE;
+  gtk_file_info_free (info);
+
+  if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, error))
+    return FALSE;
 
   if (impl->current_folder != path)
     {
@@ -2896,7 +2895,7 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser    *chooser,
       impl->current_folder = gtk_file_path_copy (path);
     }
 
-  /* Update the widgets that may trigger a folder chnage themselves */
+  /* Update the widgets that may trigger a folder change themselves.  */
 
   if (!impl->changing_folder)
     {
index 4a6d979e97ff0a400dd89343a490c19a4db73bbb..a0b24f7769dda731d6b6bc878552e14c58bb4e99 100644 (file)
@@ -784,7 +784,6 @@ gtk_path_bar_check_parent_path (GtkPathBar         *path_bar,
          current_path = list;
          break;
        }
-
     }
 
   if (current_path)
@@ -815,9 +814,12 @@ _gtk_path_bar_set_path (GtkPathBar         *path_bar,
 
   result = TRUE;
 
+  /* Check whether the new path is already present in the pathbar as buttons.
+   * This could be a parent directory or a previous selected subdirectory.
+   */
   if (gtk_path_bar_check_parent_path (path_bar, file_path, path_bar->file_system))
     return TRUE;
-      
+
   path = gtk_file_path_copy (file_path);
 
   gtk_widget_push_composite_child ();
@@ -827,43 +829,33 @@ _gtk_path_bar_set_path (GtkPathBar         *path_bar,
       GtkFilePath *parent_path = NULL;
       GtkWidget *button;
       const gchar *display_name;
-      GError *err = NULL;
       GtkFileFolder *file_folder;
       GtkFileInfo *file_info;
       gboolean valid;
-      GtkFileInfoType needed = GTK_FILE_INFO_DISPLAY_NAME;
       ButtonType button_type;
 
       valid = gtk_file_system_get_parent (path_bar->file_system,
                                          path,
                                          &parent_path,
-                                         &err);
+                                         error);
       if (!valid)
        {
          result = FALSE;
-         g_propagate_error (error, err);
          gtk_file_path_free (path);
          break;
        }
 
-      if (first_directory)
-       needed |= GTK_FILE_INFO_IS_FOLDER;
-
-      file_folder = gtk_file_system_get_folder
-       (path_bar->file_system,
-        parent_path ? parent_path : path,
-        needed,
-        NULL);
+      file_folder = gtk_file_system_get_folder (path_bar->file_system,
+                                               parent_path ? parent_path : path,
+                                               GTK_FILE_INFO_DISPLAY_NAME,
+                                               NULL);
+      file_info = gtk_file_folder_get_info (file_folder, path, error);
+      g_object_unref (file_folder);
 
-      file_info = gtk_file_folder_get_info (file_folder, path, &err);
-      if (!file_info || (first_directory && !gtk_file_info_get_is_folder (file_info)))
+      if (!file_info)
        {
          result = FALSE;
 
-         g_propagate_error (error, err);
-         if (file_info)
-           gtk_file_info_free (file_info);
-         g_object_unref (file_folder);
          gtk_file_path_free (parent_path);
          gtk_file_path_free (path);
          break;
@@ -874,15 +866,13 @@ _gtk_path_bar_set_path (GtkPathBar         *path_bar,
       button = make_directory_button (path_bar, display_name, path, first_directory);
       gtk_file_info_free (file_info);
       gtk_file_path_free (path);
-      g_object_unref (file_folder);
 
       new_buttons = g_list_prepend (new_buttons, button);
 
       button_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "gtk-path-bar-button-type"));
       if (button_type != NORMAL_BUTTON)
        {
-         if (parent_path)
-           gtk_file_path_free (parent_path);
+         gtk_file_path_free (parent_path);
          break;
        }